<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 	xmlns="http://www.w3.org/1999/xhtml"
    	xmlns:ui="http://java.sun.com/jsf/facelets"
    	xmlns:f="http://java.sun.com/jsf/core"
    	xmlns:h="http://java.sun.com/jsf/html"
    	xmlns:p="http://primefaces.org/ui"
    	xmlns:s="http://www.suricattus.com.br/jsf/ui"
		xmlns:sf="http://www.suricattus.com.br/jsf/fn"
		xmlns:ec="http://www.b2cexpress.com.br/ecommerce"
    	xmlns:composite="http://java.sun.com/jsf/composite">

	<composite:interface>	
		<composite:attribute name="controller" required="true"  />
	</composite:interface>	
	
	<composite:implementation>	
		<h:panelGroup id="dadosFinalizacao">
			<s:isAnonymous>
				<h:panelGroup id="login">
					<h:panelGroup rendered="#{not cc.attrs.controller.cadastro}">
						<div class="span6">
							<legend>#{labels['login.categoria.possuo.cadastro']}</legend>
							<ec:fieldOutput id="usuarioField" fieldId="usuario" required="true" label="#{labels['label.email']}">
								<p:inputText id="usuario" label="#{labels['label.email']}" required="true" styleClass="input-large" value="#{cc.attrs.controller.clienteManutencao.email}">
									<s:email />
								</p:inputText>
								<br />
								<ec:messages for="usuario"  />
							</ec:fieldOutput>
							<ec:fieldOutput id="senhaField" fieldId="senha" required="true" label="#{labels['label.senha']}">
								<p:password id="senha" label="#{labels['label.senha']}" required="true" styleClass="input-large" value="#{cc.attrs.controller.clienteManutencao.senha}" />
								<br />
								<ec:messages for="senha"/>
							</ec:fieldOutput>
							
							<div class="form-actions">
								<p:commandLink action="#{cc.attrs.controller.autenticarCliente}" styleClass="btn btn-success" process="login" update="dadosFinalizacao">
									<h:outputText value="#{labels['botao.entrar']}" />
								</p:commandLink>
				           </div>
						</div>
						<div class="span6">
							<legend>#{labels['login.categoria.nao.possuo.cadastro']}</legend>
							<div>
								<h:outputText value="#{labels['login.texto.nao.possui.cadastro']} " />
								<p:commandLink action="#{cc.attrs.controller.cadastrarCliente}" value="#{labels['botao.cadastre.se']}" 
										process="@this" update="dadosFinalizacao"/>
							</div>
						</div>
					</h:panelGroup>
					
					<h:panelGroup rendered="#{cc.attrs.controller.cadastro}">
						<h:panelGroup id="dadosCadastro" styleClass="form-horizontal">
					        <ec:dadosCliente id="componenteCadastro" cliente="#{cc.attrs.controller.clienteManutencao}" 
					        		endereco="#{cc.attrs.controller.endereco}" senha="true" class="span6">
								<div class="span12" align="center" style="margin: 0px;">
						        	<hr style="margin-bottom: 10px !important;" />
									<p:commandButton action="#{cc.attrs.controller.salvarNovoCliente()}" 
											value="#{labels['botao.cadastrar']}" styleClass="btn btn-success" update="@all" process="dadosCadastro"/>
									<p:spacer width="10"/> 
									<p:commandButton action="#{cc.attrs.controller.cancelarCadastro()}" 
											value="#{labels['botao.cancelar']}" styleClass="btn" update="dadosFinalizacao" process="@this"/>
								</div>
							</ec:dadosCliente>
						</h:panelGroup>
					</h:panelGroup>
					
					<div style="clear: both;" />
				</h:panelGroup>
			</s:isAnonymous>
			
			<s:isAuthenticated>
				<composite:insertChildren />
			</s:isAuthenticated>
		</h:panelGroup>
	</composite:implementation>
</html>
